import os
from pathlib import Path

from celery import Celery

project = Path(__file__).parent.resolve().name
os.environ.setdefault("DJANGO_SETTINGS_MODULE", f"{project}.settings")
from .reference import TIME_DELTA

app = Celery(project)

app.config_from_object("django.conf:settings", namespace="CELERY")
app.autodiscover_tasks()

app.conf.update(
    enable_utc=True,
    timezone="Asia/Shanghai"
)

app.conf.beat_schedule = {
    'loop-every': {
        'task': 'loop_query_task',
        'schedule': TIME_DELTA,
        'args': ()
    },
    # 'test-3s': {
    #     'task': 'test_loop',
    #     'schedule': 3,
    #     'args': ()
    # }
}
